<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Builder;

class UserBinds extends AbstractModel
{

    /**
     * 账号类型: QQ
     */
    const TYPE_QQ = 'qq';

    /**
     * 账号类型: 微信
     */
    const TYPE_WEIXIN = 'weixin';

    /**
     * 账号类型: 微博
     */
    const TYPE_WEIBO = 'weibo';

    /**
     * 账号类型: 淘宝
     */
    const TYPE_TAOBAO = 'taobao';

    /**
     * 表名
     *
     * @var string
     */
    protected $table = 'user_binds';

    /**
     * 自动维护时间
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 支持批量填充的字段
     *
     * @var array
     */
    protected $fillable = [
        'type', 'open_id', 'access_token', 'refresh_token', 'access_token_expires', 'refresh_token_expires'
    ];

    /**
     * 输出JSON时隐藏的字段
     *
     * @var array
     */
    protected $hidden = [
        'access_token', 'refresh_token', 'access_token_expires', 'refresh_token_expires'
    ];

    /**
     * 所属用户
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }
}